package com.jvm;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: tgy
 * @Date: 2020-08-03 10:35
 */
public class GCDetails {

    public static void main(String[] args) {


        List<byte[]> list = new ArrayList<>();

        for (int i = 0; i < 100; i++) {

            list.add(new byte[1000000]);
        }

        /**
         *                               年轻代使用size 回收之后的size 堆回收之前size
         * [GC (Allocation Failure) [PSYoungGen: 2048K->496K(2560K)] 2048K->673K(9728K), 0.0012674 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
         * [GC (Allocation Failure) [PSYoungGen: 1756K->496K(2560K)] 1934K->1690K(9728K), 0.0014976 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
         * [GC (Allocation Failure) [PSYoungGen: 2502K->496K(2560K)] 3696K->3659K(9728K), 0.0010059 secs] [Times: user=0.01 sys=0.00, real=0.00 secs]
         * [GC (Allocation Failure) [PSYoungGen: 2481K->496K(2560K)] 5644K->5628K(9728K), 0.0010107 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
         * [Full GC (Ergonomics) [PSYoungGen: 496K->0K(2560K)] [ParOldGen: 5132K->5388K(7168K)] 5628K->5388K(9728K), [Metaspace: 3171K->3171K(1056768K)], 0.0037537 secs] [Times: user=0.01 sys=0.00, real=0.01 secs]
         * [Full GC (Ergonomics) [PSYoungGen: 2029K->976K(2560K)] [ParOldGen: 5388K->6365K(7168K)] 7417K->7341K(9728K), [Metaspace: 3171K->3171K(1056768K)], 0.0024856 secs] [Times: user=0.01 sys=0.00, real=0.00 secs]
         * [Full GC (Ergonomics) [PSYoungGen: 1962K->1953K(2560K)] [ParOldGen: 6365K->6364K(7168K)] 8327K->8318K(9728K), [Metaspace: 3171K->3171K(1056768K)], 0.0034779 secs] [Times: user=0.01 sys=0.00, real=0.01 secs]
         * [Full GC (Allocation Failure) [PSYoungGen: 1953K->1953K(2560K)] [ParOldGen: 6364K->6346K(7168K)] 8318K->8300K(9728K), [Metaspace: 3171K->3171K(1056768K)], 0.0040023 secs] [Times: user=0.01 sys=0.00, real=0.00 secs]
         * Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
         * 	at com.jvm.GCDetails.main(GCDetails.java:19)
         * Heap
         *  PSYoungGen      total 2560K, used 2044K [0x00000007bfd00000, 0x00000007c0000000, 0x00000007c0000000)
         *   eden space 2048K, 99% used [0x00000007bfd00000,0x00000007bfeff120,0x00000007bff00000)
         *   from space 512K, 0% used [0x00000007bff80000,0x00000007bff80000,0x00000007c0000000)
         *   to   space 512K, 0% used [0x00000007bff00000,0x00000007bff00000,0x00000007bff80000)
         *  ParOldGen       total 7168K, used 6346K [0x00000007bf600000, 0x00000007bfd00000, 0x00000007bfd00000)
         *   object space 7168K, 88% used [0x00000007bf600000,0x00000007bfc32b88,0x00000007bfd00000)
         *  Metaspace       used 3228K, capacity 4496K, committed 4864K, reserved 1056768K
         *   class space    used 357K, capacity 388K, committed 512K, reserved 1048576K
         *
         *
         *   GC 的格式
         *   [区域名: 回收前所占内存->回收后所占内存(总内存)][...] 回收前堆内存->回收后堆内存[总堆内存大小] [...]
         *
         *   区域名: PSYongGen(新生代), ParOldGen(老年代), Metaspace(元空间)
         */


    }
}
